let { SyncLoopHook } = require('tapable')

class Lesson {
  constructor () {
    this.index = 0
    this.hooks = {
      arch: new SyncLoopHook(['name'])
    }
  }

  // 注册监听函数
  tap () {
    this.hooks.arch.tap('node', (name) => {
      console.log('node', name)

      return ++this.index < 3 ? '继续学' : undefined
    })
    this.hooks.arch.tap('react', (data) => {
      console.log('react', data)
    })
  }

  start () {
    this.hooks.arch.call('xyf')
  }
}

let l1 = new Lesson()

l1.tap()
l1.start() // 启动钩子

